package com.sm.imlibrary.model;

import android.text.TextUtils;
import android.widget.FrameLayout;

import com.sm.imlibrary.imsdk.SIMMessage;
import com.sm.imlibrary.nio.SocketIoManage;

/**
 * created by zhud on 2019/7/9
 */
public abstract class Message {

    SIMMessage message;
    /**
     * 消息描述信息
     */
    private String desc;

    public SIMMessage getMessage() {
        return message;
    }

    /**
     * 显示消息
     *
     * @param frameLayout 消息容器
     */
    public abstract void showMessage(FrameLayout frameLayout);

    /**
     * 判断是否是自己发的
     */
    public boolean isSelf() {
        String from = message.getChatMessage().from;
        return !TextUtils.isEmpty(from) && SocketIoManage.getInstance().getIdentifying().equals(from);
    }

    /**
     * 获取发送者
     */
    public String getSender() {
        return "发送人";
    }

    /**
     * 清除气泡原有数据
     *
     * @param frameLayout 消息容器
     */
    protected void clearView(FrameLayout frameLayout) {
        frameLayout.removeAllViews();
    }
}
